<link href="<?php echo DOMAIN; ?>/css/my-style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function del(id){
//		alert(id);
        domain = $("#domain").val();
        var comfirmBox;
		 comfirmBox = confirm("Bạn có chác chắn muốn xóa không ?");
		 if(comfirmBox == true)
		  {
			 $.ajax(
				      {
				    	  type:"POST",
						  url: domain+ "/admin/teacher/del",
						  data: "id=" + id,
						  datatype: "html",
						  success: function(html)
						     {
							  $("#row" + id).remove();
						     }
				      }
				      );
		  }
	}
</script>


<?php 
	$list = $this->list;
//	Zend_Debug::dump($list);die;
	$count = $this->count;
	$now_page = $this->now_page;
    $all_institutes= $this->all_institutes;
    //Zend_Debug::dump($all_institutes);die;
?>
    <input class='blue'   onclick="javascript:window.location='<?php echo DOMAIN_INDEX ?>/admin/teacher/add'; return false;" value="Thêm" type="button"/>
    <br class="cl" />
	<section class="grid_9" id="dashtabs" style="min-height:400px;width:100%;margin-left:0px;">
		
       <div class="box-header">
          <?php if($this->search == 1) echo "Kết quả tìm kiếm"; else echo "Danh sách giáo viên"; ?>
          <form style="float:right;" method="post" action="">
                
               <select name="id_institutes">
               <option value="0">Tất cả</option>
                <?php  
                    
                    foreach($all_institutes as $item){ ?>
                    <option <?php if($this->id_institutes==$item['id']) echo "selected='selected'" ?> value="<?php echo $item['id'] ?>"><?php echo $item['name']; ?></option>    
                        
                <?php } ?>
               </select>     
               <input placeholder="Họ tên" value="<?php echo $this->name_search; ?>" style="width:150px;"  type="text" name="name_search" />
          	 <input  type="submit" value="Tìm kiếm" />
          </form>
        </div>
        
        <div id="dashtabs-comments" class="box-content no-padding">
        <input type="hidden" value="<?php echo DOMAIN_INDEX; ?>" id="domain"/>  
          <table class="table no-border">
            <thead>
              <tr>
               <td align="center" width="3%">STT</td>
                <td align="center" width="15%">Tên GV</td>
                <td align="center" width="8%">Khoa/Viện</td>
                <td align="center" width="15%">Email</td>
                <td align="center" width="8%">Phone</td>
                <td align="center" width="8%">Username </td>
                <td align="center" width="8%">Trạng thái </td>
                <td class="last" width="10%">Tùy chọn</td>
              </tr>
            </thead>
            <tbody>
              <?php 
                $i = 1;
              	foreach ($list as $key => $value) {
              		
              		?>
              		<tr <?php if($i%2) echo "class='alt'"; ?> id="<?php echo "row".$value["id"] ?>">
		                <td align="center"><?php echo $i; ?></td>
		                <td ><?php echo $value["name"] ?></td>
		                
                        <td align="center"><?php echo $value["i_name"] ?></td>
		                
                        <td align="center"><?php echo $value["email"] ?></td>
		                <td align="center"><?php echo $value["phone"] ?></td>
                        <td align="center"><?php echo $value["username"] ?></td>
                        <td align="center"><?php if($value["status"]==1)echo 'ON'; else echo 'OFF' ;?></td>
		                <td align='center' class="last">
		                	
                            <a href="<?php echo DOMAIN_INDEX; ?>/admin/teacher/edit?id=<?php echo $value["id"] ?>" class="tooltip" title="Chỉnh sửa SV"><img alt="edit comment" src="<?php echo DOMAIN ?>/images/icons/16/comment_edit.png"></a>
		                	<span class="tooltip" onclick="del(<?php echo $value["id"] ?>)" title="Xóa SV"><img alt="delete comment" src="<?php echo DOMAIN ?>/images/icons/16/comment_delete.png"/></span>
		                </td>
		            </tr>
              		<?php
              		$i++;
              	}
              ?>
              
            </tbody>
          </table>
        </div>
        <?php 
        	if($this->search == 0){
        ?>
	        <div class="box-footer"> <span class="txt-smaller txt-light">Showing <?php echo count($list);?> results of <?php echo $count;?> </span>
		    	<ul class="pagination">
		    		<?php 
						if($count > 30){
							if($count%30 == 0){
								$page_count = (int)($count/30)-1;
							} else $page_count =  (int)($count/30);
						    if($now_page==1){
						    	echo "<li><a title='Current Page ' class='current' href ='".DOMAIN_INDEX."/teacher/index/page/1'>[1]</a></li>";
						    	echo "<li><a title='Page 2' href ='".DOMAIN_INDEX."/admin/teacher/index/page/2'>2</a></li>";
						    	echo "<li><a title='Page 3' href ='".DOMAIN_INDEX."/admin/teacher/index/page/3'>3</a></li>";
						    	echo "<li><a title='Next Page' href='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page+1)."'> Next &gt; </a></li>";
								echo "<li><a title='Last Page' href ='".DOMAIN_INDEX."/admin/teacher/index/page/".($page_count+1)."'> Last &gt;&gt;</a></li>";
						    }
						    elseif($now_page==$page_count+1){
						    	echo "<li><a title='First Page' href = '".DOMAIN_INDEX."/admin/teacher/index/page/1'> &lt;&lt; First</a></li>";
								echo "<li><a title='Previous Page' href='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page-1)."'> &lt; Prev </a></li>";
						    	echo "<li><a title='Page ".($now_page-2)."' href ='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page-2)."'>".($now_page-2)."</a></li>";
						    	echo "<li><a title='Page ".($now_page-1)."' href ='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page-1)."'>".($now_page-1)."</a></li>";
						    	echo "<li><a title='Current Page' class='current' href ='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page)."'>[".($now_page)."]</a></li>";
						    }	
							else{
								echo "<li><a title='First Page' href = '".DOMAIN_INDEX."/admin/teacher/index/page/1'> &lt;&lt; First</a></li>";
								echo "<li><a title='Previous Page' href='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page-1)."'> &lt; Prev </a></li>";
								echo "<li><a title='Page ".($now_page-1)."' href ='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page-1)."'>".($now_page-1)."</a></li>";
								echo "<li><a title='Current Page' class='current' href ='".DOMAIN_INDEX."/admin/teacher/index/page/".$now_page."'>[".$now_page."]</a></li>";
								echo "<li><a title='Page ".($now_page+1)."' href ='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page+1)."'>".($now_page+1)."</a></li>";
								echo "<li><a title='Next Page' href='".DOMAIN_INDEX."/admin/teacher/index/page/".($now_page+1)."'> Next &gt; </a></li>";
								echo "<li><a title='Last Page' href ='".DOMAIN_INDEX."/admin/teacher/index/page/".($page_count+1)."'> Last &gt;&gt;</a></li>";
							}
						} 
					?>	
		  
		      	</ul>
	    	</div>
	    <?php } ?>
    </section>
    
    <br class="cl" />
    <br />

        <br class="cl">